<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ list.length }}</strong></span
    >
    <ul class="filters">
      <li v-for="(item, index) in arr" :key="index">
        <a
          :class="{ selected: index === i }"
          href="javascript:;"
          @click="toggle(index)"
          >{{ item }}</a
        >
      </li>
    </ul>

    <button class="clear-completed" @click="clear">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: ["list"],
  data() {
    return {
      arr: ["全部", "未完成", "已完成"],
      i: 0,
    };
  },
  methods: {
    toggle(index) {
      this.i = index;
      this.$emit("tggleFn", index);
    },
    clear() {
      this.$emit("clearFn");
    },
  },
};
</script>
